<template></template>

<script>
import { GetShopInfo } from "@/request/api";
export default {
  data() {
    return {
      code1: ""
    };
  },
  mounted() {
    this.getGetShopCity();
    this.getUrlCode();
  },
  methods: {
    getGetShopCity() {
      GetShopInfo({}).then(res => {
        console.log(res);
        if (res.code == 200) {
         
        this.code1 = this.getUrlCode.code;
        } else {
          // this.$Message.error(res.error.msg);
        }
      });
    },
     getCode() {
      //非静默授权，第一次有弹框
      this.code = "";
      var local = window.location.href; // 获取页面url
      var appid = "wx29c2e0f0ff339adf";
      this.code = this.getUrlCode().code; // 截取code
      if (this.code == null || this.code ==="") {
        // 如果没有code，则去请求
        window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
      } else {
        //你自己的业务逻辑
      }
    },
    getUrlCode(){
      var url ='http://www.cloud-aiti.com/register?code=001DC5ho0h9MPn1FNBio0HGHgo0DC5hp&state=';
        console.log(url)
        //获取code
        var codeIndex = url.indexOf('code')
        var stateIndex = url.indexOf('&state')
        var code = url.substring(codeIndex + 5, stateIndex)
        console.log(code)
    }
  }
};
</script>
<!-- <template>
 <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm login-container">
 <el-form-item label="账号" prop="name">
  <el-input v-model="ruleForm.name"></el-input>
 </el-form-item>
  <el-form-item label="密码" prop="pass">
  <el-input type="password" v-model="ruleForm.pass" auto-complete="off"></el-input>
 </el-form-item>
 <el-form-item>
  <el-button type="primary" @click="submitForm">提交</el-button>
 </el-form-item>
 </el-form>
</template>
 
<script>
export default {
 data() {
  return {
   ruleForm: {
    name: '',
    pass: ''
   },
   rules: {
    name: [
     { required: true, message: '请输入登录账号', trigger: 'blur' }
    ],
    pass: [
     { required: true, message: '请输入登录密码', trigger: 'blur' }
    ]
   }
  }
 },
} -->
<style>
</style>